/**
 * Created by zby on 2018/4/19.
 */

import java.lang.*;
import java.sql.*;
public class Country {
    public static void main(String args[]) {
        Connection con=null;
        Statement sql;
        ResultSet rs;
        try{  Class.forName("com.mysql.jdbc.Driver");
        }
        catch(Exception e){}
        String uri = "jdbc:mysql://localhost:3306/world?useSSL=true";
        String user ="root";
        String password ="";
        String sqlStr="select * from country where Region Like 'Middle East'";
        try{
            con = DriverManager.getConnection(uri,user,password);
        }
        catch(SQLException e){ }
        long sum=0;
        try {
            sql=con.createStatement();
            rs=sql.executeQuery(sqlStr);
            while(rs.next()) {

                int Population=rs.getInt(7);
                sum=sum+Population;
            }
            System.out.println("中东总人口为"+sum);
            con.close();
        }
        catch(SQLException e) {
            System.out.println(e);

        }

    }
}